<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      template="../../templates/adminTemplate.xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    
    <ui:define name="top">
        <h2> Administration des sujets </h2>
        <div class="absoluteTopRight">
            <h:outputLink value="#{subjectThread.basePath}/index.xhtml">
                Accueil
            </h:outputLink>
        </div>
    </ui:define>
    <ui:define name="content">
            <h:outputLink styleClass="modifySubjectLink modifySubjectLink_new" value="#">
                Ajouter un nouveau sujet
            </h:outputLink>
            <div class="adminSubjectForm  adminFormSubject_new">
                <h:form>
                    <h:outputLabel value="Modifiez le titre : "/>
                    <h:inputText value="#{subjectThread.newSubject.title}"/><br/>
                    <h:outputLabel value="Père actuel : "/>
                    <h:outputText styleClass="subjectFatherTitle_new" value="#{subjectThread.currentSubject.title}"/>
                    <a href="#" class="chooseSubjectFather" id="adminSubjectFatherLink_new">
                        Modifier le père
                    </a>
                    <a href="#" class="cancelSubjectFather" id="cancelSubjectFather_new">
                        Annuler
                    </a>
                    <span id="adminSubjectFatherUuid_new">
                        <h:inputHidden value="#{subjectThread.newSubject.myFather.uuid}" />
                    </span>
                    <span class="pickFatherExplication">
                        Veuillez choisir un père en cliquant sur le lien "choisir" du choisi
                    </span>
                    <br/>
                    <h:commandButton value="Ajouter" action="#{subjectThread.addNewSubject()}" />
                </h:form>
            </div>

            <h:dataTable value="#{subjectThread.subjectList}" var="subject">
                <h:column>
                    <div class="adminSubject adminSubjectDepth_#{subject.depthLayer}">
                        <span>
                            <h:outputLink value="#{subjectThread.basePath}/subjects-threads.xhtml?uuid=#{subject.uuid}">
                                <span id="subjectTitle_#{subject.uuid}">
                                    <h:outputText value="#{subject.title}"/>
                                </span>
                            </h:outputLink> 
                        </span> 
                        <h:outputLink styleClass="chooseSubjectFatherLink chooseSubjectFatherLink_#{subject.uuid}" value="#" rendered="#{empty subject.myThreads}">
                            Choisir
                        </h:outputLink> 

                        <h:outputLink styleClass="modifySubjectLink modifySubjectLink_#{subject.uuid}" value="#" rendered="#{not empty subject.myFather}">
                            Modifier
                        </h:outputLink> 

                        <h:panelGroup layout="block" styleClass="adminSubjectForm adminSubjextFormDepth_#{subject.depthLayer} adminFormSubject_#{subject.uuid}" rendered="#{not empty subject.myFather}">
                           <h:form>
                               <h:outputLabel value="Modifiez le titre : "/>
                               <h:inputText value="#{subject.title}"/><br/>
                               <h:outputLabel value="Père actuel : "/>
                               <h:outputText styleClass="subjectFatherTitle_#{subject.uuid}" value="#{subject.myFather.title}"/>
                               <a href="#" class="chooseSubjectFather" id="adminSubjectFatherLink_#{subject.uuid}">
                                   Modifier le père
                               </a>
                               <a href="#" class="cancelSubjectFather" id="cancelSubjectFather_#{subject.uuid}">
                                   Annuler
                               </a>
                               <span class="pickFatherExplication">
                                   Veuillez choisir un père en cliquant sur le lien "choisir" du choisi
                               </span>
                               <span id="adminSubjectFatherUuid_#{subject.uuid}">
                                   <h:inputHidden value="#{subject.myFather.uuid}" />
                               </span>
                               <h:inputHidden value="#{subject.uuid}"/>
                               <br/>
                               <h:commandButton value="Modifier" action="#{subjectThread.modifySubject(subject)}" />
                           </h:form>
                        </h:panelGroup>
                    </div>
                </h:column>
            </h:dataTable>
        </ui:define>
</ui:composition>